package cn.krui.project;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.data.redis.core.StringRedisTemplate;

import cn.krui.project.pubsub.system.SubThreadSystem;

/**
 * @author zc
 * system 模块的订阅和发布
 */
@Configuration
public class PubSubConfigSystem {
    @Value("${spring.redis.host:127.0.0.1}")
    private String springRedisHost;
    @Value("${spring.redis.port:6379}")
    private int springRedisPort;
    @Value("${spring.redis.timeout:6000}")
    private int springRedisTimeout;
    @Value("${spring.redis.password:}")
    private String springRedisPassword;
    
    @Autowired
    private StringRedisTemplate redisTemplate;

    @Bean
    @Scope
    public SubThreadSystem subThreadSystem() {
        // System消息订阅者
        SubThreadSystem subThread = new SubThreadSystem(springRedisHost,springRedisPort,springRedisTimeout,springRedisPassword,redisTemplate);
        subThread.start();
        return subThread;
    }
}